﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Data;
using GPCSC.Webs;
using System.Text;
using ExtAspNet;

namespace GPCSC.Web.SHFW
{
    public partial class userlist : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                F_bound();
            }
        }
        protected void F_bound()
        {
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            ds = new SqlReadXml().ReaderDataSet("sel_user_all", htable);
            if (ds.Tables.Count > 0)
            {
                Grid1.DataSource = ds.Tables[0];
                Grid1.DataBind();
            }

        }
        protected void Grid1_PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
        }
        protected void ttbSearch_Trigger1Click(object sender, EventArgs e)
        {
            F_bound();
        }

        protected void ttbSearch_Trigger2Click(object sender, EventArgs e)
        {
          
            string username = ttbSearch.Text.Trim();
            if (username == "")
            {
                F_bound();
            }
            else
            {
                Hashtable htable = new Hashtable();
                username = "%" + username + "%";
                htable.Add("@like", username);
                DataSet ds = new SqlReadXml().ReaderDataSet("sel_user_bylike", htable);
                if (ds.Tables.Count > 0)
                {
                    Grid1.DataSource = ds.Tables[0];
                    Grid1.DataBind();
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            

            string sb = "";
            //string sbs = "";
            int selectedCount = Grid1.SelectedRowIndexArray.Length;
            if (selectedCount > 0)
            {

                sb += "<ul>";
                foreach (int row in Grid1.SelectedRowIndexArray)
                {
                    sb += "<li value='" + Grid1.DataKeys[row][0].ToString() + "' style=' float:left'> " + Grid1.DataKeys[row][1].ToString() + " &nbsp;</li>";
                 

                }
                PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(sb) + ActiveWindow.GetHideReference());
                sb += "</ul>";
            }
            else
            {
            
                Alert.Show("您没有选中任何行");

            }
        }




    }
}